<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage" :autoLoad="false">
    </ex_super_table_page>
  </div>
</template>

<script>
import business_function from "@/common/business_function"
import superTablePageFunction from "@/mixin/super-table-page-function";

export default {
  name: "label_rent_detail",
  title: 'label_rent_detail',
  mixins: [  superTablePageFunction,],

  components: {},
  data() {
    return {
      option: {
        //搜索框内容
        search: {
          //搜索框内容，key为搜索字段，label为标签提示
          model: [
            {
              label: "label_snapshot_time",
              key: "backupName",
              type: 'select',
              url: '/wms-api/stock/WmsStockHistoryRpc/showTableNames.json',
              option: { label: 'label', value: 'value' },
              on: {
                'initList': (result) => {
                  // console.log(this.$refs['SuperTablePage']);
                  if (!_.isEmpty(result)) {
                    this.$refs['SuperTablePage'].$refs['search'].set("backupName", result[0].value)
                    this.$refs['SuperTablePage'].loadDataForSearch()
                  }

                }
              }

            },

            { label: "label_customer", key: "customerId", type: 'common_customer_choose', },
            { label: "label_sku", key: "skuId", type: 'sku_selec_input', },
            {
              label: "label_putaway_time",
              key: "putawayTimeStart",
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            {
              label: "-",
              key: "putawayTimeEnd",
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
          ],
        },
        actionExtra: [
          {
            label: 'label_export', click: this.exportExcel
          },
        ],
        table: {
          url: "/wms-api/stock/WmsStockHistoryRpc/stockContainerQuery.json?rent=Y",
          attrs: {

          },
          model: [
            {
              key: 'skuOnlyCode', label: 'label_sku_info', formatter: (r, c, v, i) => {
                return '[' + v + '] ' + r['skuName']
              }
            },
            {
              key: 'customerCode', label: 'label_customer_info', formatter: (r, c, v, i) => {
                return '[' + v + '] ' + r['customerName']
              }
            },
            {
              key: 'putawayTime', label: 'label_putaway_time', formatter: (r, c, v, i) => this.$dateFormat(v)
            },
            {
              key: 'areaCode', label: 'label_warehouse_area_code',
            },
            {
              key: 'locationCode', label: 'label_warehouse_location',
            },
            {
              key: 'totalQty', label: 'label_sum',
            },
            {
              key: 'skuVolume', label: 'label_volume',
            },
            {
              key: 'stockAge', label: 'label_snapshot_stock'
            },
            {
              key: 'rentAmount', label: 'label_warehouse_rent_amount', formatter: (r, c, v, i) => v + ' ' + r['currencyType']
            }
          ],

        },

      },
    }
  },
  methods: {
    exportExcel() {
      const searchParams = this.$refs.SuperTablePage.getSearchData()
      business_function.confirmOperateBaseSelectOrForm.call(this, {
        data: searchParams,
        model: this.option.search.model,
        callback: (selection, data) => {
          let params = data
          this.$functionCommon({
            url: "/wms-api/stock/WmsStockHistoryRpc/stockContainerRentExportExcel.json?rent=Y",
            data: params, type: 'form',
          })
        }
      })
    },
  }

}
</script>

<style scoped></style>
